#include <algorithm>
#include <array>
#include<vector>

class Solution {
public:
    int fieldOfGreatestBlessing(std::vector<std::vector<int>>& forceField) {
        std::array<long long,200> x_array{};
        std::array<long long,200> y_array{};
        std::array<std::array<int ,202>,202> z_array{};
        
        int n = forceField.size();
        for(int i=0;i<n;i++)
        {
           x_array[i*2] = static_cast<long long>(static_cast<long long>(forceField[i][0]) << 1ll )-static_cast<long long >(forceField[i][2]);
            x_array[i*2+1] =static_cast<long long> (static_cast<long long>(forceField[i][0]) << 1ll )+static_cast<long long >(forceField[i][2]);
            y_array[i*2] =static_cast<long long> (static_cast<long long>(forceField[i][1]) << 1ll )-static_cast<long long >(forceField[i][2]);
            y_array[i*2+1] = static_cast<long long>(static_cast<long long>(forceField[i][1]) << 1ll ) +static_cast<long long >(forceField[i][2]);
        }
        int x_len = sortAndSet(x_array,n*2);
        int y_len = sortAndSet(y_array,n*2);
        
        for(int i=0;i<n;i++)
        {
            int a= binSearch(x_array,0,x_len, static_cast<long long>(static_cast<long long>(forceField[i][0]) << 1ll )-static_cast<long long >(forceField[i][2]) );
            int c= binSearch(x_array,0,x_len, static_cast<long long> (static_cast<long long>(forceField[i][0]) << 1ll )+static_cast<long long >(forceField[i][2]) );
            int b= binSearch(y_array,0,y_len, static_cast<long long> (static_cast<long long>(forceField[i][1]) << 1ll )-static_cast<long long >(forceField[i][2])   );
            int d= binSearch(y_array,0,y_len,  static_cast<long long>(static_cast<long long>(forceField[i][1]) << 1ll ) +static_cast<long long >(forceField[i][2]) );
            build(z_array,a,b,c,d);
        }

       return build2 (z_array,x_len+1,y_len+2);
     
    }
    int  sortAndSet(std::array<long long,200>& x,int len)
    {
        std::sort(x.begin(),x.begin()+len);
        int start = 0;
        for (int i=1;i<len;i++)
        {
            if (x[start] != x[i])
            {
                
                x[++start] = x[i];
            }
        }
        return start;
    }
    int binSearch(const std::array< long long,200>& x,int l,int r,long long target)
    {
        while (l<=r)
        {
            int mid = (l+r)/2;
            if (x[mid] < target)
            {
                l = mid + 1;
            }
            else if (x[mid] > target)
            {
                r = mid - 1;
            }
            else
            {
                return mid;
            }
        }
        return (l+r)/2;
    }
    void build(std::array<std::array<int ,202>,202>& x,int a,int b, int c,int d)
    {
        a++;
        b++;
        c++;
        d++;
        x[a][b] ++;
        x[c+1][b]--;
        x[a][d+1]--;
        x[c+1][d+1]++;
    }
    int build2(std::array<std::array<int ,202>,202>& x,int height,int width)
    {
        int max = 0;
        for (int i=1;i<width;i++)
        {
            for (int j=1;j<height;j++)
            {
                x[i][j] += x[i-1][j] + x[i][j-1] -x[i-1][j-1];
                max = std::max(max,x[i][j]);
            }
        }
        return max;
    }
};
